<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<html>
<head>
<title>
 Overview
</title>
<link rel ="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script>
function asd() {
	
		parent.document.title="xmlsax.js Overview";
	
}
</script>
</head>
<body bgcolor="white" onload="asd();">

<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> 	<font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top">
<em>
<b></b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<center>
	
	   <h2>xmlsax.js</h2>
	
</center>

	


<h4>Summary</h4>
<p>
	
		No overview generated for 'xmlsax.js'<BR/><BR/>
	
</p>

<hr>



<!-- ========== METHOD SUMMARY =========== -->

	<a name="method_summary"><!-- --></a>
	<table border="1" cellpadding="3" cellspacing="0" width="100%">
		<tr bgcolor="#CCCCFF" class="TableHeadingColor">
			<td colspan=2>
				<font size="+2">
					<b>Method Summary</b>
				</font>
			</td>
		</tr>
	
		
		   <tr bgcolor="white" class="TableRowColor">
		      <td align="right" valign="top" width="1%">
			 <font size="-1">
			    <code>static&nbsp;Object</code>
			 </font>
		      </td>
		      <td>
			 <code>
			    <b>
			       <a href="GLOBALS.html#!s!__escapeString">__escapeString</a></b>(str)
			 </code>
			 <br>
			 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			 function __escapeString


		      </td>
		   </tr>
		
		   <tr bgcolor="white" class="TableRowColor">
		      <td align="right" valign="top" width="1%">
			 <font size="-1">
			    <code>static&nbsp;Object</code>
			 </font>
		      </td>
		      <td>
			 <code>
			    <b>
			       <a href="GLOBALS.html#!s!__unescapeString">__unescapeString</a></b>(str)
			 </code>
			 <br>
			 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			 function __unescapeString 


		      </td>
		   </tr>
		
		   <tr bgcolor="white" class="TableRowColor">
		      <td align="right" valign="top" width="1%">
			 <font size="-1">
			    <code>static&nbsp;Object</code>
			 </font>
		      </td>
		      <td>
			 <code>
			    <b>
			       <a href="GLOBALS.html#!s!isEmpty">isEmpty</a></b>(str)
			 </code>
			 <br>
			 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			 
		      </td>
		   </tr>
		
		   <tr bgcolor="white" class="TableRowColor">
		      <td align="right" valign="top" width="1%">
			 <font size="-1">
			    <code>static&nbsp;Object</code>
			 </font>
		      </td>
		      <td>
			 <code>
			    <b>
			       <a href="GLOBALS.html#!s!trim">trim</a></b>(trimString, leftTrim, rightTrim)
			 </code>
			 <br>
			 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			 
		      </td>
		   </tr>
		
	
	</table>
    <p>

<!-- ========== END METHOD SUMMARY =========== -->


        <pre class="sourceview"><span class="comment">// =========================================================================</span>
<span class="comment">//</span>
<span class="comment">// xmlsax.js - an XML SAX parser in JavaScript.</span>
<span class="comment">//</span>
<span class="comment">// version 3.1</span>
<span class="comment">//</span>
<span class="comment">// =========================================================================</span>
<span class="comment">//</span>
<span class="comment">// Copyright (C) 2001 - 2002 David Joham (djoham<span class="attrib">@yahoo</span>.com) and Scott Severtson</span>
<span class="comment">//</span>
<span class="comment">// This library is free software; you can redistribute it and/or</span>
<span class="comment">// modify it under the terms of the GNU Lesser General Public</span>
<span class="comment">// License as published by the Free Software Foundation; either</span>
<span class="comment">// version 2.1 of the License, or (at your option) any later version.</span>

<span class="comment">// This library is distributed in the hope that it will be useful,</span>
<span class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<span class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU</span>
<span class="comment">// Lesser General Public License for more details.</span>

<span class="comment">// You should have received a copy of the GNU Lesser General Public</span>
<span class="comment">// License along with this library; if not, write to the Free Software</span>
<span class="comment">// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA</span>
<span class="comment">//</span>
<span class="comment">//</span>
<span class="comment">// Visit the XML for &lt;SCRIPT&gt; home page at http://xmljs.sourceforge.net</span>
<span class="comment">//</span>

<span class="comment">// CONSTANTS</span>

<span class="comment">// =========================================================================</span>
<span class="comment">// =========================================================================</span>
<span class="comment">// =========================================================================</span>
var whitespace = <span class="literal">"\n\r\t "</span>;


<span class="comment">/***************************************************************************************************************
XMLP is a pull-based parser. The calling application passes in a XML string
to the constructor, then repeatedly calls .next() to parse the next segment.
.next() returns a flag indicating what type of segment was found, and stores
data temporarily in couple member variables (name, content, array of
attributes), which can be accessed by several .get____() methods.

Basically, XMLP is the lowest common denominator parser - an very simple
API which other wrappers can be built against.
*****************************************************************************************************************/</span>


XMLP = <span class="reserved">function</span>(strXML) {
    <span class="comment">/*******************************************************************************************************************
    function:   this is the constructor to the XMLP Object

    Author:   Scott Severtson

    Description:
        Instantiates and initializes the object
    *********************************************************************************************************************/</span>
    <span class="comment">// Normalize line breaks</span>
    strXML = SAXStrings.replace(strXML, null, null, <span class="literal">"\r\n"</span>, <span class="literal">"\n"</span>);
    strXML = SAXStrings.replace(strXML, null, null, <span class="literal">"\r"</span>, <span class="literal">"\n"</span>);

    <span class="reserved">this</span>.m_xml = strXML;
    <span class="reserved">this</span>.m_iP = 0;
    <span class="reserved">this</span>.m_iState = XMLP._STATE_PROLOG;
    <span class="reserved">this</span>.m_stack = new Stack();
    <span class="reserved">this</span>._clearAttributes();

}  <span class="comment">// end XMLP constructor</span>


<span class="comment">// CONSTANTS    (these must be below the constructor)</span>

<span class="comment">// =========================================================================</span>
<span class="comment">// =========================================================================</span>
<span class="comment">// =========================================================================</span>

XMLP._NONE    = 0;
XMLP._ELM_B   = 1;
XMLP._ELM_E   = 2;
XMLP._ELM_EMP = 3;
XMLP._ATT     = 4;
XMLP._TEXT    = 5;
XMLP._ENTITY  = 6;
XMLP._PI      = 7;
XMLP._CDATA   = 8;
XMLP._COMMENT = 9;
XMLP._DTD     = 10;
XMLP._ERROR   = 11;

XMLP._CONT_XML = 0;
XMLP._CONT_ALT = 1;

XMLP._ATT_NAME = 0;
XMLP._ATT_VAL  = 1;

XMLP._STATE_PROLOG = 1;
XMLP._STATE_DOCUMENT = 2;
XMLP._STATE_MISC = 3;

XMLP._errs = [];
XMLP._errs[XMLP.ERR_CLOSE_PI       = 0 ] = <span class="literal">"PI: missing closing sequence"</span>;
XMLP._errs[XMLP.ERR_CLOSE_DTD      = 1 ] = <span class="literal">"DTD: missing closing sequence"</span>;
XMLP._errs[XMLP.ERR_CLOSE_COMMENT  = 2 ] = <span class="literal">"Comment: missing closing sequence"</span>;
XMLP._errs[XMLP.ERR_CLOSE_CDATA    = 3 ] = <span class="literal">"CDATA: missing closing sequence"</span>;
XMLP._errs[XMLP.ERR_CLOSE_ELM      = 4 ] = <span class="literal">"Element: missing closing sequence"</span>;
XMLP._errs[XMLP.ERR_CLOSE_ENTITY   = 5 ] = <span class="literal">"Entity: missing closing sequence"</span>;
XMLP._errs[XMLP.ERR_PI_TARGET      = 6 ] = <span class="literal">"PI: target is required"</span>;
XMLP._errs[XMLP.ERR_ELM_EMPTY      = 7 ] = <span class="literal">"Element: cannot be both empty and closing"</span>;
XMLP._errs[XMLP.ERR_ELM_NAME       = 8 ] = <span class="literal">"Element: name must immediatly follow \"</span>&lt;\<span class="literal">""</span>;
XMLP._errs[XMLP.ERR_ELM_LT_NAME    = 9 ] = <span class="literal">"Element: \"</span>&lt;\<span class="literal">" not allowed in element names"</span>;
XMLP._errs[XMLP.ERR_ATT_VALUES     = 10] = <span class="literal">"Attribute: values are required and must be in quotes"</span>;
XMLP._errs[XMLP.ERR_ATT_LT_NAME    = 11] = <span class="literal">"Element: \"</span>&lt;\<span class="literal">" not allowed in attribute names"</span>;
XMLP._errs[XMLP.ERR_ATT_LT_VALUE   = 12] = <span class="literal">"Attribute: \"</span>&lt;\<span class="literal">" not allowed in attribute values"</span>;
XMLP._errs[XMLP.ERR_ATT_DUP        = 13] = <span class="literal">"Attribute: duplicate attributes not allowed"</span>;
XMLP._errs[XMLP.ERR_ENTITY_UNKNOWN = 14] = <span class="literal">"Entity: unknown entity"</span>;
XMLP._errs[XMLP.ERR_INFINITELOOP   = 15] = <span class="literal">"Infininte loop"</span>;
XMLP._errs[XMLP.ERR_DOC_STRUCTURE  = 16] = <span class="literal">"Document: only comments, processing instructions, or whitespace allowed outside of document element"</span>;
XMLP._errs[XMLP.ERR_ELM_NESTING    = 17] = <span class="literal">"Element: must be nested correctly"</span>;

<span class="comment">// =========================================================================</span>
<span class="comment">// =========================================================================</span>
<span class="comment">// =========================================================================</span>


XMLP.<span class="reserved">prototype</span>._addAttribute = <span class="reserved">function</span>(name, value) {
    <span class="comment">/*******************************************************************************************************************
    function:   _addAttribute

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>
    <span class="reserved">this</span>.m_atts[<span class="reserved">this</span>.m_atts.length] = new Array(name, value);
}  <span class="comment">// end function _addAttribute</span>


XMLP.<span class="reserved">prototype</span>._checkStructure = <span class="reserved">function</span>(iEvent) {
    <span class="comment">/*******************************************************************************************************************
    function:   _checkStructure

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>
  
	<span class="reserved">if</span>(XMLP._STATE_PROLOG == <span class="reserved">this</span>.m_iState) {
		<span class="reserved">if</span>((XMLP._TEXT == iEvent) || (XMLP._ENTITY == iEvent)) {
            <span class="reserved">if</span>(SAXStrings.indexOfNonWhitespace(<span class="reserved">this</span>.getContent(), <span class="reserved">this</span>.getContentBegin(), <span class="reserved">this</span>.getContentEnd()) != -1) {
				<span class="reserved">return</span> <span class="reserved">this</span>._setErr(XMLP.ERR_DOC_STRUCTURE);
            }
        }

        <span class="reserved">if</span>((XMLP._ELM_B == iEvent) || (XMLP._ELM_EMP == iEvent)) {
            <span class="reserved">this</span>.m_iState = XMLP._STATE_DOCUMENT;
            <span class="comment">// Don't return - fall through to next state</span>
        }
    }
    <span class="reserved">if</span>(XMLP._STATE_DOCUMENT == <span class="reserved">this</span>.m_iState) {
        <span class="reserved">if</span>((XMLP._ELM_B == iEvent) || (XMLP._ELM_EMP == iEvent)) {
            <span class="reserved">this</span>.m_stack.push(<span class="reserved">this</span>.getName());
        }

        <span class="reserved">if</span>((XMLP._ELM_E == iEvent) || (XMLP._ELM_EMP == iEvent)) {
            var strTop = <span class="reserved">this</span>.m_stack.pop();
            <span class="reserved">if</span>((strTop===null) || (strTop != <span class="reserved">this</span>.getName())) {
                <span class="reserved">return</span> <span class="reserved">this</span>._setErr(XMLP.ERR_ELM_NESTING);
            }
        }

        <span class="reserved">if</span>(<span class="reserved">this</span>.m_stack.count() === 0) {
            <span class="reserved">this</span>.m_iState = XMLP._STATE_MISC;
            <span class="reserved">return</span> iEvent;
        }
    }
    <span class="reserved">if</span>(XMLP._STATE_MISC == <span class="reserved">this</span>.m_iState) {
		<span class="reserved">if</span>((XMLP._ELM_B == iEvent) || (XMLP._ELM_E == iEvent) || (XMLP._ELM_EMP == iEvent) || (XMLP.EVT_DTD == iEvent)) {
			<span class="reserved">return</span> <span class="reserved">this</span>._setErr(XMLP.ERR_DOC_STRUCTURE);
        }

        <span class="reserved">if</span>((XMLP._TEXT == iEvent) || (XMLP._ENTITY == iEvent)) {
			<span class="reserved">if</span>(SAXStrings.indexOfNonWhitespace(<span class="reserved">this</span>.getContent(), <span class="reserved">this</span>.getContentBegin(), <span class="reserved">this</span>.getContentEnd()) != -1) {
				<span class="reserved">return</span> <span class="reserved">this</span>._setErr(XMLP.ERR_DOC_STRUCTURE);
            }
        }
    }

    <span class="reserved">return</span> iEvent;

}  <span class="comment">// end function _checkStructure</span>


XMLP.<span class="reserved">prototype</span>._clearAttributes = <span class="reserved">function</span>() {
    <span class="comment">/*******************************************************************************************************************
    function:   _clearAttributes

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>
    <span class="reserved">this</span>.m_atts = [];
}  <span class="comment">// end function _clearAttributes</span>


XMLP.<span class="reserved">prototype</span>._findAttributeIndex = <span class="reserved">function</span>(name) {
    <span class="comment">/*******************************************************************************************************************
    function:   findAttributeIndex

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>
    <span class="reserved">for</span>(var i = 0; i &lt; <span class="reserved">this</span>.m_atts.length; i++) {
        <span class="reserved">if</span>(<span class="reserved">this</span>.m_atts[i][XMLP._ATT_NAME] == name) {
            <span class="reserved">return</span> i;
        }
    }
    <span class="reserved">return</span> -1;

}  <span class="comment">// end function _findAttributeIndex</span>


XMLP.<span class="reserved">prototype</span>.getAttributeCount = <span class="reserved">function</span>() {
    <span class="comment">/*******************************************************************************************************************
    function:   getAttributeCount

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>

    <span class="reserved">return</span> <span class="reserved">this</span>.m_atts ? <span class="reserved">this</span>.m_atts.length : 0;

}  <span class="comment">// end function getAttributeCount()</span>


XMLP.<span class="reserved">prototype</span>.getAttributeName = <span class="reserved">function</span>(index) {
    <span class="comment">/*******************************************************************************************************************
    function:   getAttributeName

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>

    <span class="reserved">return</span> ((index &lt; 0) || (index &gt;= <span class="reserved">this</span>.m_atts.length)) ? null : <span class="reserved">this</span>.m_atts[index][XMLP._ATT_NAME];

}  <span class="comment">//end function getAttributeName</span>


XMLP.<span class="reserved">prototype</span>.getAttributeValue = <span class="reserved">function</span>(index) {
    <span class="comment">/*******************************************************************************************************************
    function:   getAttributeValue

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>

    <span class="reserved">return</span> ((index &lt; 0) || (index &gt;= <span class="reserved">this</span>.m_atts.length)) ? null : __unescapeString(<span class="reserved">this</span>.m_atts[index][XMLP._ATT_VAL]);

} <span class="comment">// end function getAttributeValue</span>


XMLP.<span class="reserved">prototype</span>.getAttributeValueByName = <span class="reserved">function</span>(name) {
    <span class="comment">/*******************************************************************************************************************
    function:   getAttributeValueByName

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>

    <span class="reserved">return</span> <span class="reserved">this</span>.getAttributeValue(<span class="reserved">this</span>._findAttributeIndex(name));

}  <span class="comment">// end function getAttributeValueByName</span>


XMLP.<span class="reserved">prototype</span>.getColumnNumber = <span class="reserved">function</span>() {
    <span class="comment">/*******************************************************************************************************************
    function:   getColumnNumber

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>

    <span class="reserved">return</span> SAXStrings.getColumnNumber(<span class="reserved">this</span>.m_xml, <span class="reserved">this</span>.m_iP);

}  <span class="comment">// end function getColumnNumber</span>


XMLP.<span class="reserved">prototype</span>.getContent = <span class="reserved">function</span>() {
    <span class="comment">/*******************************************************************************************************************
    function:   getContent

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>

    <span class="reserved">return</span> (<span class="reserved">this</span>.m_cSrc == XMLP._CONT_XML) ? <span class="reserved">this</span>.m_xml : <span class="reserved">this</span>.m_cAlt;

}  <span class="comment">//end function getContent</span>


XMLP.<span class="reserved">prototype</span>.getContentBegin = <span class="reserved">function</span>() {
    <span class="comment">/*******************************************************************************************************************
    function:   getContentBegin

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>

    <span class="reserved">return</span> <span class="reserved">this</span>.m_cB;

}  <span class="comment">//end function getContentBegin</span>


XMLP.<span class="reserved">prototype</span>.getContentEnd = <span class="reserved">function</span>() {
    <span class="comment">/*******************************************************************************************************************
    function:   getContentEnd

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>

    <span class="reserved">return</span> <span class="reserved">this</span>.m_cE;

}  <span class="comment">// end function getContentEnd</span>


XMLP.<span class="reserved">prototype</span>.getLineNumber = <span class="reserved">function</span>() {
    <span class="comment">/*******************************************************************************************************************
    function:   getLineNumber

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>

    <span class="reserved">return</span> SAXStrings.getLineNumber(<span class="reserved">this</span>.m_xml, <span class="reserved">this</span>.m_iP);

}  <span class="comment">// end function getLineNumber</span>


XMLP.<span class="reserved">prototype</span>.getName = <span class="reserved">function</span>() {
    <span class="comment">/*******************************************************************************************************************
    function:   getName

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>

    <span class="reserved">return</span> <span class="reserved">this</span>.m_name;

}  <span class="comment">// end function getName()</span>


XMLP.<span class="reserved">prototype</span>.next = <span class="reserved">function</span>() {
    <span class="comment">/*******************************************************************************************************************
    function:   next

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>

    <span class="reserved">return</span> <span class="reserved">this</span>._checkStructure(<span class="reserved">this</span>._parse());

}  <span class="comment">// end function next()</span>


XMLP.<span class="reserved">prototype</span>._parse = <span class="reserved">function</span>() {
    <span class="comment">/*******************************************************************************************************************
    function:   _parse

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>

	<span class="reserved">if</span>(<span class="reserved">this</span>.m_iP == <span class="reserved">this</span>.m_xml.length) {
        <span class="reserved">return</span> XMLP._NONE;
    }

    <span class="reserved">if</span>(<span class="reserved">this</span>.m_iP == <span class="reserved">this</span>.m_xml.indexOf(<span class="literal">"&lt;?"</span>,        <span class="reserved">this</span>.m_iP)) {
        <span class="reserved">return</span> <span class="reserved">this</span>._parsePI     (<span class="reserved">this</span>.m_iP + 2);
    }
    <span class="reserved">else</span> <span class="reserved">if</span>(<span class="reserved">this</span>.m_iP == <span class="reserved">this</span>.m_xml.indexOf(<span class="literal">"&lt;!DOCTYPE"</span>, <span class="reserved">this</span>.m_iP)) {
        <span class="reserved">return</span> <span class="reserved">this</span>._parseDTD    (<span class="reserved">this</span>.m_iP + 9);
    }
    <span class="reserved">else</span> <span class="reserved">if</span>(<span class="reserved">this</span>.m_iP == <span class="reserved">this</span>.m_xml.indexOf(<span class="literal">"&lt;!--"</span>,      <span class="reserved">this</span>.m_iP)) {
        <span class="reserved">return</span> <span class="reserved">this</span>._parseComment(<span class="reserved">this</span>.m_iP + 4);
    }
    <span class="reserved">else</span> <span class="reserved">if</span>(<span class="reserved">this</span>.m_iP == <span class="reserved">this</span>.m_xml.indexOf(<span class="literal">"&lt;![CDATA["</span>, <span class="reserved">this</span>.m_iP)) {
        <span class="reserved">return</span> <span class="reserved">this</span>._parseCDATA  (<span class="reserved">this</span>.m_iP + 9);
    }
    <span class="reserved">else</span> <span class="reserved">if</span>(<span class="reserved">this</span>.m_iP == <span class="reserved">this</span>.m_xml.indexOf(<span class="literal">"&lt;"</span>,         <span class="reserved">this</span>.m_iP)) {
        <span class="reserved">return</span> <span class="reserved">this</span>._parseElement(<span class="reserved">this</span>.m_iP + 1);
    }
    <span class="reserved">else</span> <span class="reserved">if</span>(<span class="reserved">this</span>.m_iP == <span class="reserved">this</span>.m_xml.indexOf(<span class="literal">"&amp;"</span>,         <span class="reserved">this</span>.m_iP)) {
        <span class="reserved">return</span> <span class="reserved">this</span>._parseEntity (<span class="reserved">this</span>.m_iP + 1);
    }
    <span class="reserved">else</span>{
        <span class="reserved">return</span> <span class="reserved">this</span>._parseText   (<span class="reserved">this</span>.m_iP);
    }
	

}  <span class="comment">// end function _parse</span>


XMLP.<span class="reserved">prototype</span>._parseAttribute = <span class="reserved">function</span>(iB, iE) {
    <span class="comment">/*******************************************************************************************************************
    function:   _parseAttribute

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>
    var iNB, iNE, iEq, iVB, iVE;
    var cQuote, strN, strV;

	<span class="reserved">this</span>.m_cAlt = <span class="literal">""</span>; <span class="comment">//resets the value so we don't use an old one by accident (see testAttribute7 in the test suite)</span>
    
	iNB = SAXStrings.indexOfNonWhitespace(<span class="reserved">this</span>.m_xml, iB, iE);
    <span class="reserved">if</span>((iNB == -1) ||(iNB &gt;= iE)) {
        <span class="reserved">return</span> iNB;
    }

    iEq = <span class="reserved">this</span>.m_xml.indexOf(<span class="literal">"="</span>, iNB);
    <span class="reserved">if</span>((iEq == -1) || (iEq &gt; iE)) {
        <span class="reserved">return</span> <span class="reserved">this</span>._setErr(XMLP.ERR_ATT_VALUES);
    }

    iNE = SAXStrings.lastIndexOfNonWhitespace(<span class="reserved">this</span>.m_xml, iNB, iEq);

    iVB = SAXStrings.indexOfNonWhitespace(<span class="reserved">this</span>.m_xml, iEq + 1, iE);
    <span class="reserved">if</span>((iVB == -1) ||(iVB &gt; iE)) {
        <span class="reserved">return</span> <span class="reserved">this</span>._setErr(XMLP.ERR_ATT_VALUES);
    }

    cQuote = <span class="reserved">this</span>.m_xml.charAt(iVB);
    <span class="reserved">if</span>(SAXStrings.QUOTES.indexOf(cQuote) == -1) {
        <span class="reserved">return</span> <span class="reserved">this</span>._setErr(XMLP.ERR_ATT_VALUES);
    }

    iVE = <span class="reserved">this</span>.m_xml.indexOf(cQuote, iVB + 1);
    <span class="reserved">if</span>((iVE == -1) ||(iVE &gt; iE)) {
        <span class="reserved">return</span> <span class="reserved">this</span>._setErr(XMLP.ERR_ATT_VALUES);
    }

    strN = <span class="reserved">this</span>.m_xml.substring(iNB, iNE + 1);
    strV = <span class="reserved">this</span>.m_xml.substring(iVB + 1, iVE);

    <span class="reserved">if</span>(strN.indexOf(<span class="literal">"&lt;"</span>) != -1) {
        <span class="reserved">return</span> <span class="reserved">this</span>._setErr(XMLP.ERR_ATT_LT_NAME);
    }

    <span class="reserved">if</span>(strV.indexOf(<span class="literal">"&lt;"</span>) != -1) {
        <span class="reserved">return</span> <span class="reserved">this</span>._setErr(XMLP.ERR_ATT_LT_VALUE);
    }

    strV = SAXStrings.replace(strV, null, null, <span class="literal">"\n"</span>, <span class="literal">" "</span>);
    strV = SAXStrings.replace(strV, null, null, <span class="literal">"\t"</span>, <span class="literal">" "</span>);
	iRet = <span class="reserved">this</span>._replaceEntities(strV);
    <span class="reserved">if</span>(iRet == XMLP._ERROR) {
        <span class="reserved">return</span> iRet;
    }

    strV = <span class="reserved">this</span>.m_cAlt;

    <span class="reserved">if</span>(<span class="reserved">this</span>._findAttributeIndex(strN) == -1) {
        <span class="reserved">this</span>._addAttribute(strN, strV);
    }
    <span class="reserved">else</span> {
        <span class="reserved">return</span> <span class="reserved">this</span>._setErr(XMLP.ERR_ATT_DUP);
    }

    <span class="reserved">this</span>.m_iP = iVE + 2;

    <span class="reserved">return</span> XMLP._ATT;

}  <span class="comment">// end function _parseAttribute</span>


XMLP.<span class="reserved">prototype</span>._parseCDATA = <span class="reserved">function</span>(iB) {
    <span class="comment">/*******************************************************************************************************************
    function:   _parseCDATA

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>
    var iE = <span class="reserved">this</span>.m_xml.indexOf(<span class="literal">"]]&gt;"</span>, iB);
    <span class="reserved">if</span> (iE == -1) {
        <span class="reserved">return</span> <span class="reserved">this</span>._setErr(XMLP.ERR_CLOSE_CDATA);
    }

    <span class="reserved">this</span>._setContent(XMLP._CONT_XML, iB, iE);

    <span class="reserved">this</span>.m_iP = iE + 3;

    <span class="reserved">return</span> XMLP._CDATA;

}  <span class="comment">// end function _parseCDATA</span>


XMLP.<span class="reserved">prototype</span>._parseComment = <span class="reserved">function</span>(iB) {
    <span class="comment">/*******************************************************************************************************************
    function:   _parseComment

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>
    var iE = <span class="reserved">this</span>.m_xml.indexOf(<span class="literal">"-"</span> + <span class="literal">"-&gt;"</span>, iB);
    <span class="reserved">if</span> (iE == -1) {
        <span class="reserved">return</span> <span class="reserved">this</span>._setErr(XMLP.ERR_CLOSE_COMMENT);
    }

    <span class="reserved">this</span>._setContent(XMLP._CONT_XML, iB, iE);

    <span class="reserved">this</span>.m_iP = iE + 3;

    <span class="reserved">return</span> XMLP._COMMENT;

}  <span class="comment">// end function _parseComment</span>


XMLP.<span class="reserved">prototype</span>._parseDTD = <span class="reserved">function</span>(iB) {
    <span class="comment">/*******************************************************************************************************************
    function:  _parseDTD

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>

    <span class="comment">// Eat DTD</span>

    var iE, strClose, iInt, iLast;

    iE = <span class="reserved">this</span>.m_xml.indexOf(<span class="literal">"&gt;"</span>, iB);
    <span class="reserved">if</span>(iE == -1) {
        <span class="reserved">return</span> <span class="reserved">this</span>._setErr(XMLP.ERR_CLOSE_DTD);
    }

    iInt = <span class="reserved">this</span>.m_xml.indexOf(<span class="literal">"["</span>, iB);
    strClose = ((iInt != -1) &amp;&amp; (iInt &lt; iE)) ? <span class="literal">"]&gt;"</span> : <span class="literal">"&gt;"</span>;

    <span class="reserved">while</span>(true) {
        <span class="comment">// DEBUG: Remove</span>
        <span class="reserved">if</span>(iE == iLast) {
            <span class="reserved">return</span> <span class="reserved">this</span>._setErr(XMLP.ERR_INFINITELOOP);
        }

        iLast = iE;
        <span class="comment">// DEBUG: Remove End</span>

        iE = <span class="reserved">this</span>.m_xml.indexOf(strClose, iB);
        <span class="reserved">if</span>(iE == -1) {
            <span class="reserved">return</span> <span class="reserved">this</span>._setErr(XMLP.ERR_CLOSE_DTD);
        }

        <span class="comment">// Make sure it is not the end of a CDATA section</span>
        <span class="reserved">if</span> (<span class="reserved">this</span>.m_xml.substring(iE - 1, iE + 2) != <span class="literal">"]]&gt;"</span>) {
            break;
        }
    }

    <span class="reserved">this</span>.m_iP = iE + strClose.length;

    <span class="reserved">return</span> XMLP._DTD;

}  <span class="comment">// end function _parseDTD</span>


XMLP.<span class="reserved">prototype</span>._parseElement = <span class="reserved">function</span>(iB) {
    <span class="comment">/*******************************************************************************************************************
    function:   _parseElement

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>
    var iE, iDE, iNE, iRet;
    var iType, strN, iLast;

    iDE = iE = <span class="reserved">this</span>.m_xml.indexOf(<span class="literal">"&gt;"</span>, iB);
    <span class="reserved">if</span>(iE == -1) {
        <span class="reserved">return</span> <span class="reserved">this</span>._setErr(XMLP.ERR_CLOSE_ELM);
    }

    <span class="reserved">if</span>(<span class="reserved">this</span>.m_xml.charAt(iB) == <span class="literal">"/"</span>) {
        iType = XMLP._ELM_E;
        iB++;
    } <span class="reserved">else</span> {
        iType = XMLP._ELM_B;
    }

    <span class="reserved">if</span>(<span class="reserved">this</span>.m_xml.charAt(iE - 1) == <span class="literal">"/"</span>) {
        <span class="reserved">if</span>(iType == XMLP._ELM_E) {
            <span class="reserved">return</span> <span class="reserved">this</span>._setErr(XMLP.ERR_ELM_EMPTY);
        }
        iType = XMLP._ELM_EMP;
        iDE--;
    }

    iDE = SAXStrings.lastIndexOfNonWhitespace(<span class="reserved">this</span>.m_xml, iB, iDE);

    <span class="comment">//djohack</span>
    <span class="comment">//hack to allow for elements with single character names to be recognized</span>

    <span class="reserved">if</span> (iE - iB != 1 ) {
        <span class="reserved">if</span>(SAXStrings.indexOfNonWhitespace(<span class="reserved">this</span>.m_xml, iB, iDE) != iB) {
            <span class="reserved">return</span> <span class="reserved">this</span>._setErr(XMLP.ERR_ELM_NAME);
        }
    }
    <span class="comment">// end hack -- original code below</span>

    <span class="comment">/*
    if(SAXStrings.indexOfNonWhitespace(this.m_xml, iB, iDE) != iB)
        return this._setErr(XMLP.ERR_ELM_NAME);
    */</span>
    <span class="reserved">this</span>._clearAttributes();

    iNE = SAXStrings.indexOfWhitespace(<span class="reserved">this</span>.m_xml, iB, iDE);
    <span class="reserved">if</span>(iNE == -1) {
        iNE = iDE + 1;
    }
    <span class="reserved">else</span> {
        <span class="reserved">this</span>.m_iP = iNE;
        <span class="reserved">while</span>(<span class="reserved">this</span>.m_iP &lt; iDE) {
            <span class="comment">// DEBUG: Remove</span>
            <span class="reserved">if</span>(<span class="reserved">this</span>.m_iP == iLast) <span class="reserved">return</span> <span class="reserved">this</span>._setErr(XMLP.ERR_INFINITELOOP);
            iLast = <span class="reserved">this</span>.m_iP;
            <span class="comment">// DEBUG: Remove End</span>


            iRet = <span class="reserved">this</span>._parseAttribute(<span class="reserved">this</span>.m_iP, iDE);
            <span class="reserved">if</span>(iRet == XMLP._ERROR) <span class="reserved">return</span> iRet;
        }
    }

    strN = <span class="reserved">this</span>.m_xml.substring(iB, iNE);

    <span class="reserved">if</span>(strN.indexOf(<span class="literal">"&lt;"</span>) != -1) {
        <span class="reserved">return</span> <span class="reserved">this</span>._setErr(XMLP.ERR_ELM_LT_NAME);
    }

    <span class="reserved">this</span>.m_name = strN;
    <span class="reserved">this</span>.m_iP = iE + 1;

    <span class="reserved">return</span> iType;

}  <span class="comment">// end function _parseElement</span>


XMLP.<span class="reserved">prototype</span>._parseEntity = <span class="reserved">function</span>(iB) {
    <span class="comment">/*******************************************************************************************************************
    function:   _parseEntity

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>
    var iE = <span class="reserved">this</span>.m_xml.indexOf(<span class="literal">";"</span>, iB);
    <span class="reserved">if</span>(iE == -1) {
        <span class="reserved">return</span> <span class="reserved">this</span>._setErr(XMLP.ERR_CLOSE_ENTITY);
    }

    <span class="reserved">this</span>.m_iP = iE + 1;

    <span class="reserved">return</span> <span class="reserved">this</span>._replaceEntity(<span class="reserved">this</span>.m_xml, iB, iE);

}  <span class="comment">// end function _parseEntity</span>


XMLP.<span class="reserved">prototype</span>._parsePI = <span class="reserved">function</span>(iB) {
    <span class="comment">/*******************************************************************************************************************
    function:   _parsePI

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>

    var iE, iTB, iTE, iCB, iCE;

    iE = <span class="reserved">this</span>.m_xml.indexOf(<span class="literal">"?&gt;"</span>, iB);
    <span class="reserved">if</span>(iE   == -1) {
        <span class="reserved">return</span> <span class="reserved">this</span>._setErr(XMLP.ERR_CLOSE_PI);
    }

    iTB = SAXStrings.indexOfNonWhitespace(<span class="reserved">this</span>.m_xml, iB, iE);
    <span class="reserved">if</span>(iTB == -1) {
        <span class="reserved">return</span> <span class="reserved">this</span>._setErr(XMLP.ERR_PI_TARGET);
    }

    iTE = SAXStrings.indexOfWhitespace(<span class="reserved">this</span>.m_xml, iTB, iE);
    <span class="reserved">if</span>(iTE  == -1) {
        iTE = iE;
    }

    iCB = SAXStrings.indexOfNonWhitespace(<span class="reserved">this</span>.m_xml, iTE, iE);
    <span class="reserved">if</span>(iCB == -1) {
        iCB = iE;
    }

    iCE = SAXStrings.lastIndexOfNonWhitespace(<span class="reserved">this</span>.m_xml, iCB, iE);
    <span class="reserved">if</span>(iCE  == -1) {
        iCE = iE - 1;
    }

    <span class="reserved">this</span>.m_name = <span class="reserved">this</span>.m_xml.substring(iTB, iTE);
    <span class="reserved">this</span>._setContent(XMLP._CONT_XML, iCB, iCE + 1);
    <span class="reserved">this</span>.m_iP = iE + 2;

    <span class="reserved">return</span> XMLP._PI;

}  <span class="comment">// end function _parsePI</span>


XMLP.<span class="reserved">prototype</span>._parseText = <span class="reserved">function</span>(iB) {
    <span class="comment">/*******************************************************************************************************************
    function:   _parseText

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>
    var iE, iEE;

    iE = <span class="reserved">this</span>.m_xml.indexOf(<span class="literal">"&lt;"</span>, iB);
    <span class="reserved">if</span>(iE == -1) {
        iE = <span class="reserved">this</span>.m_xml.length;
    }

    iEE = <span class="reserved">this</span>.m_xml.indexOf(<span class="literal">"&amp;"</span>, iB);
    <span class="reserved">if</span>((iEE != -1) &amp;&amp; (iEE &lt;= iE)) {
        iE = iEE;
    }

    <span class="reserved">this</span>._setContent(XMLP._CONT_XML, iB, iE);

    <span class="reserved">this</span>.m_iP = iE;

    <span class="reserved">return</span> XMLP._TEXT;

} <span class="comment">// end function _parseText</span>


XMLP.<span class="reserved">prototype</span>._replaceEntities = <span class="reserved">function</span>(strD, iB, iE) {
    <span class="comment">/*******************************************************************************************************************
    function:   _replaceEntities

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>
    <span class="reserved">if</span>(SAXStrings.isEmpty(strD)) <span class="reserved">return</span> <span class="literal">""</span>;
    iB = iB || 0;
    iE = iE || strD.length;


    var iEB, iEE, strRet = <span class="literal">""</span>;

    iEB = strD.indexOf(<span class="literal">"&amp;"</span>, iB);
    iEE = iB;

    <span class="reserved">while</span>((iEB &gt; 0) &amp;&amp; (iEB &lt; iE)) {
        strRet += strD.substring(iEE, iEB);

        iEE = strD.indexOf(<span class="literal">";"</span>, iEB) + 1;

        <span class="reserved">if</span>((iEE === 0) || (iEE &gt; iE)) {
            <span class="reserved">return</span> <span class="reserved">this</span>._setErr(XMLP.ERR_CLOSE_ENTITY);
        }

        iRet = <span class="reserved">this</span>._replaceEntity(strD, iEB + 1, iEE - 1);
        <span class="reserved">if</span>(iRet == XMLP._ERROR) {
            <span class="reserved">return</span> iRet;
        }

        strRet += <span class="reserved">this</span>.m_cAlt;

        iEB = strD.indexOf(<span class="literal">"&amp;"</span>, iEE);
    }

    <span class="reserved">if</span>(iEE != iE) {
        strRet += strD.substring(iEE, iE);
    }

    <span class="reserved">this</span>._setContent(XMLP._CONT_ALT, strRet);

    <span class="reserved">return</span> XMLP._ENTITY;

}  <span class="comment">// end function _replaceEntities</span>


XMLP.<span class="reserved">prototype</span>._replaceEntity = <span class="reserved">function</span>(strD, iB, iE) {
    <span class="comment">/*******************************************************************************************************************
    function:   _replaceEntity

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>
    <span class="reserved">if</span>(SAXStrings.isEmpty(strD)) <span class="reserved">return</span> -1;
    iB = iB || 0;
    iE = iE || strD.length;

    switch(strD.substring(iB, iE)) {
        case <span class="literal">"amp"</span>:  strEnt = <span class="literal">"&amp;"</span>;  break;
        case <span class="literal">"lt"</span>:   strEnt = <span class="literal">"&lt;"</span>;  break;
        case <span class="literal">"gt"</span>:   strEnt = <span class="literal">"&gt;"</span>;  break;
        case <span class="literal">"apos"</span>: strEnt = <span class="literal">"'"</span>;  break;
        case <span class="literal">"quot"</span>: strEnt = <span class="literal">"\"</span><span class="literal">"; break;
        default:
            if(strD.charAt(iB) == "</span>#<span class="literal">") {
                strEnt = String.fromCharCode(parseInt(strD.substring(iB + 1, iE)));
            } else {
                return this._setErr(XMLP.ERR_ENTITY_UNKNOWN);
            }
        break;
    }
    this._setContent(XMLP._CONT_ALT, strEnt);

    return XMLP._ENTITY;
}  // end function _replaceEntity


XMLP.prototype._setContent = function(iSrc) {
    /*******************************************************************************************************************
    function:   _setContent

    Author:   Scott Severtson
    *********************************************************************************************************************/
    var args = arguments;

    if(XMLP._CONT_XML == iSrc) {
        this.m_cAlt = null;
        this.m_cB = args[1];
        this.m_cE = args[2];
    } else {
        this.m_cAlt = args[1];
        this.m_cB = 0;
        this.m_cE = args[1].length;
    }
    this.m_cSrc = iSrc;

}  // end function _setContent


XMLP.prototype._setErr = function(iErr) {
    /*******************************************************************************************************************
    function:   _setErr

    Author:   Scott Severtson
    *********************************************************************************************************************/
    var strErr = XMLP._errs[iErr];

    this.m_cAlt = strErr;
    this.m_cB = 0;
    this.m_cE = strErr.length;
    this.m_cSrc = XMLP._CONT_ALT;

    return XMLP._ERROR;

}  // end function _setErr






/***************************************************************************************************************
SAXDriver is an object that basically wraps an XMLP instance, and provides an
event-based interface for parsing. This is the object users interact with when coding
with XML for &lt;SCRIPT&gt;
*****************************************************************************************************************/


SAXDriver = function() {
    /*******************************************************************************************************************
    function:   SAXDriver

    Author:   Scott Severtson

    Description:
        This is the constructor for the SAXDriver Object
    *********************************************************************************************************************/
    this.m_hndDoc = null;
    this.m_hndErr = null;
    this.m_hndLex = null;
};


// CONSTANTS    (these must be below the constructor)

// =========================================================================
// =========================================================================
// =========================================================================
SAXDriver.DOC_B = 1;
SAXDriver.DOC_E = 2;
SAXDriver.ELM_B = 3;
SAXDriver.ELM_E = 4;
SAXDriver.CHARS = 5;
SAXDriver.PI    = 6;
SAXDriver.CD_B  = 7;
SAXDriver.CD_E  = 8;
SAXDriver.CMNT  = 9;
SAXDriver.DTD_B = 10;
SAXDriver.DTD_E = 11;
// =========================================================================
// =========================================================================
// =========================================================================



SAXDriver.prototype.parse = function(strD) {
    /*******************************************************************************************************************
    function:   parse

    Author:   Scott Severtson
    *********************************************************************************************************************/
    var parser = new XMLP(strD);

    if(this.m_hndDoc &amp;&amp; this.m_hndDoc.setDocumentLocator) {
        this.m_hndDoc.setDocumentLocator(this);
    }

    this.m_parser = parser;
    this.m_bErr = false;

    if(!this.m_bErr) {
        this._fireEvent(SAXDriver.DOC_B);
    }
    this._parseLoop();
    if(!this.m_bErr) {
        this._fireEvent(SAXDriver.DOC_E);
    }

    this.m_xml = null;
    this.m_iP = 0;

}  // end function parse


SAXDriver.prototype.setDocumentHandler = function(hnd) {
    /*******************************************************************************************************************
    function:   setDocumentHandler

    Author:   Scott Severtson
    *********************************************************************************************************************/

    this.m_hndDoc = hnd;

}   // end function setDocumentHandler


SAXDriver.prototype.setErrorHandler = function(hnd) {
    /*******************************************************************************************************************
    function:   setErrorHandler

    Author:   Scott Severtson
    *********************************************************************************************************************/

    this.m_hndErr = hnd;

}  // end function setErrorHandler


SAXDriver.prototype.setLexicalHandler = function(hnd) {
    /*******************************************************************************************************************
    function:   setLexicalHandler

    Author:   Scott Severtson
    *********************************************************************************************************************/

    this.m_hndLex = hnd;

}  // end function setLexicalHandler


    /*******************************************************************************************************************
                                                LOCATOR/PARSE EXCEPTION INTERFACE
    *********************************************************************************************************************/

SAXDriver.prototype.getColumnNumber = function() {
    /*******************************************************************************************************************
    function:   getSystemId

    Author:   Scott Severtson
    *********************************************************************************************************************/

    return this.m_parser.getColumnNumber();

}  // end function getColumnNumber


SAXDriver.prototype.getLineNumber = function() {
    /*******************************************************************************************************************
    function:   getLineNumber

    Author:   Scott Severtson
    *********************************************************************************************************************/

    return this.m_parser.getLineNumber();

}  // end function getLineNumber


SAXDriver.prototype.getMessage = function() {
    /*******************************************************************************************************************
    function:   getMessage

    Author:   Scott Severtson
    *********************************************************************************************************************/

    return this.m_strErrMsg;

}  // end function getMessage


SAXDriver.prototype.getPublicId = function() {
    /*******************************************************************************************************************
    function:   getPublicID

    Author:   Scott Severtson
    *********************************************************************************************************************/

    return null;

}  // end function getPublicID


SAXDriver.prototype.getSystemId = function() {
    /*******************************************************************************************************************
    function:   getSystemId

    Author:   Scott Severtson
    *********************************************************************************************************************/

    return null;

}  // end function getSystemId


    /*******************************************************************************************************************
                                                Attribute List Interface
    *********************************************************************************************************************/

SAXDriver.prototype.getLength = function() {
    /*******************************************************************************************************************
    function:   getLength

    Author:   Scott Severtson
    *********************************************************************************************************************/

    return this.m_parser.getAttributeCount();

}  // end function getAttributeCount


SAXDriver.prototype.getName = function(index) {
    /*******************************************************************************************************************
    function:   getName

    Author:   Scott Severtson
    *********************************************************************************************************************/

    return this.m_parser.getAttributeName(index);

} // end function getAttributeName


SAXDriver.prototype.getValue = function(index) {
    /*******************************************************************************************************************
    function:   getValue

    Author:   Scott Severtson
    *********************************************************************************************************************/

    return this.m_parser.getAttributeValue(index);

}  // end function getAttributeValue


SAXDriver.prototype.getValueByName = function(name) {
    /*******************************************************************************************************************
    function:   getValueByName

    Author:   Scott Severtson
    *********************************************************************************************************************/

    return this.m_parser.getAttributeValueByName(name);

} // end function getAttributeValueByName


    /*******************************************************************************************************************
                                                                Private functions
    *********************************************************************************************************************/

SAXDriver.prototype._fireError = function(strMsg) {
    /*******************************************************************************************************************
    function:   _fireError

    Author:   Scott Severtson
    *********************************************************************************************************************/
    this.m_strErrMsg = strMsg;
    this.m_bErr = true;

    if(this.m_hndErr &amp;&amp; this.m_hndErr.fatalError) {
        this.m_hndErr.fatalError(this);
    }

}   // end function _fireError


SAXDriver.prototype._fireEvent = function(iEvt) {
    /*******************************************************************************************************************
    function:   _fireEvent

    Author:   Scott Severtson
    *********************************************************************************************************************/
    var hnd, func, args = arguments, iLen = args.length - 1;

    if(this.m_bErr) return;

    if(SAXDriver.DOC_B == iEvt) {
        func = "</span>startDocument<span class="literal">";         hnd = this.m_hndDoc;
    }
    else if (SAXDriver.DOC_E == iEvt) {
        func = "</span>endDocument<span class="literal">";           hnd = this.m_hndDoc;
    }
    else if (SAXDriver.ELM_B == iEvt) {
        func = "</span>startElement<span class="literal">";          hnd = this.m_hndDoc;
    }
    else if (SAXDriver.ELM_E == iEvt) {
        func = "</span>endElement<span class="literal">";            hnd = this.m_hndDoc;
    }
    else if (SAXDriver.CHARS == iEvt) {
        func = "</span>characters<span class="literal">";            hnd = this.m_hndDoc;
    }
    else if (SAXDriver.PI    == iEvt) {
        func = "</span>processingInstruction<span class="literal">"; hnd = this.m_hndDoc;
    }
    else if (SAXDriver.CD_B  == iEvt) {
        func = "</span>startCDATA<span class="literal">";            hnd = this.m_hndLex;
    }
    else if (SAXDriver.CD_E  == iEvt) {
        func = "</span>endCDATA<span class="literal">";              hnd = this.m_hndLex;
    }
    else if (SAXDriver.CMNT  == iEvt) {
        func = "</span>comment<span class="literal">";               hnd = this.m_hndLex;
    }

    if(hnd &amp;&amp; hnd[func]) {
        if(0 == iLen) {
            hnd[func]();
        }
        else if (1 == iLen) {
            hnd[func](args[1]);
        }
        else if (2 == iLen) {
            hnd[func](args[1], args[2]);
        }
        else if (3 == iLen) {
            hnd[func](args[1], args[2], args[3]);
        }
    }

}  // end function _fireEvent


SAXDriver.prototype._parseLoop = function(parser) {
    /*******************************************************************************************************************
    function:   _parseLoop

    Author:   Scott Severtson
    *********************************************************************************************************************/
    var iEvent, parser;

    parser = this.m_parser;
    while(!this.m_bErr) {
        iEvent = parser.next();

        if(iEvent == XMLP._ELM_B) {
            this._fireEvent(SAXDriver.ELM_B, parser.getName(), this);
        }
        else if(iEvent == XMLP._ELM_E) {
            this._fireEvent(SAXDriver.ELM_E, parser.getName());
        }
        else if(iEvent == XMLP._ELM_EMP) {
            this._fireEvent(SAXDriver.ELM_B, parser.getName(), this);
            this._fireEvent(SAXDriver.ELM_E, parser.getName());
        }
        else if(iEvent == XMLP._TEXT) {
            this._fireEvent(SAXDriver.CHARS, parser.getContent(), parser.getContentBegin(), parser.getContentEnd() - parser.getContentBegin());
        }
        else if(iEvent == XMLP._ENTITY) {
            this._fireEvent(SAXDriver.CHARS, parser.getContent(), parser.getContentBegin(), parser.getContentEnd() - parser.getContentBegin());
        }
        else if(iEvent == XMLP._PI) {
            this._fireEvent(SAXDriver.PI, parser.getName(), parser.getContent().substring(parser.getContentBegin(), parser.getContentEnd()));
        }
        else if(iEvent == XMLP._CDATA) {
            this._fireEvent(SAXDriver.CD_B);
            this._fireEvent(SAXDriver.CHARS, parser.getContent(), parser.getContentBegin(), parser.getContentEnd() - parser.getContentBegin());
            this._fireEvent(SAXDriver.CD_E);
        }
        else if(iEvent == XMLP._COMMENT) {
            this._fireEvent(SAXDriver.CMNT, parser.getContent(), parser.getContentBegin(), parser.getContentEnd() - parser.getContentBegin());
        }
        else if(iEvent == XMLP._DTD) {
        }
        else if(iEvent == XMLP._ERROR) {
            this._fireError(parser.getContent());
        }
        else if(iEvent == XMLP._NONE) {
            return;
        }
    }

}  // end function _parseLoop



/***************************************************************************************************************
SAXStrings: a useful object containing string manipulation functions
*****************************************************************************************************************/


SAXStrings = function() {
    /*******************************************************************************************************************
    function:   SAXStrings

    Author:   Scott Severtson

    Description:
        This is the constructor of the SAXStrings object
    *********************************************************************************************************************/
}  // end function SAXStrings


// CONSTANTS    (these must be below the constructor)

// =========================================================================
// =========================================================================
// =========================================================================
SAXStrings.WHITESPACE = "</span> \t\n\r<span class="literal">";
SAXStrings.QUOTES = "</span>\<span class="literal">"'"</span>;
<span class="comment">// =========================================================================</span>
<span class="comment">// =========================================================================</span>
<span class="comment">// =========================================================================</span>


SAXStrings.getColumnNumber = <span class="reserved">function</span>(strD, iP) {
    <span class="comment">/*******************************************************************************************************************
    function:   replace

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>
    <span class="reserved">if</span>(SAXStrings.isEmpty(strD)) {
        <span class="reserved">return</span> -1;
    }
    iP = iP || strD.length;

    var arrD = strD.substring(0, iP).split(<span class="literal">"\n"</span>);
    var strLine = arrD[arrD.length - 1];
    arrD.length--;
    var iLinePos = arrD.join(<span class="literal">"\n"</span>).length;

    <span class="reserved">return</span> iP - iLinePos;

}  <span class="comment">// end function getColumnNumber</span>


SAXStrings.getLineNumber = <span class="reserved">function</span>(strD, iP) {
    <span class="comment">/*******************************************************************************************************************
    function:   getLineNumber

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>
    <span class="reserved">if</span>(SAXStrings.isEmpty(strD)) {
        <span class="reserved">return</span> -1;
    }
    iP = iP || strD.length;

    <span class="reserved">return</span> strD.substring(0, iP).split(<span class="literal">"\n"</span>).length
}  <span class="comment">// end function getLineNumber</span>


SAXStrings.indexOfNonWhitespace = <span class="reserved">function</span>(strD, iB, iE) {
    <span class="comment">/*******************************************************************************************************************
    function:   indexOfNonWhitespace

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>
    <span class="reserved">if</span>(SAXStrings.isEmpty(strD)) {
        <span class="reserved">return</span> -1;
    }
    iB = iB || 0;
    iE = iE || strD.length;

    <span class="reserved">for</span>(var i = iB; i &lt; iE; i++){
        <span class="reserved">if</span>(SAXStrings.WHITESPACE.indexOf(strD.charAt(i)) == -1) {
            <span class="reserved">return</span> i;
        }
    }
    <span class="reserved">return</span> -1;

}  <span class="comment">// end function indexOfNonWhitespace</span>


SAXStrings.indexOfWhitespace = <span class="reserved">function</span>(strD, iB, iE) {
    <span class="comment">/*******************************************************************************************************************
    function:   indexOfWhitespace

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>
    <span class="reserved">if</span>(SAXStrings.isEmpty(strD)) {
        <span class="reserved">return</span> -1;
    }
    iB = iB || 0;
    iE = iE || strD.length;

    <span class="reserved">for</span>(var i = iB; i &lt; iE; i++) {
        <span class="reserved">if</span>(SAXStrings.WHITESPACE.indexOf(strD.charAt(i)) != -1) {
            <span class="reserved">return</span> i;
        }
    }
    <span class="reserved">return</span> -1;
}  <span class="comment">// end function indexOfWhitespace</span>


SAXStrings.isEmpty = <span class="reserved">function</span>(strD) {
    <span class="comment">/*******************************************************************************************************************
    function:   isEmpty

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>

    <span class="reserved">return</span> (strD===null) || (strD.length === 0);

}  <span class="comment">// end function isEmpty</span>


SAXStrings.lastIndexOfNonWhitespace = <span class="reserved">function</span>(strD, iB, iE) {
    <span class="comment">/*******************************************************************************************************************
    function:   lastIndexOfNonWhiteSpace

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>
    <span class="reserved">if</span>(SAXStrings.isEmpty(strD)) {
        <span class="reserved">return</span> -1;
    }
    iB = iB || 0;
    iE = iE || strD.length;

    <span class="reserved">for</span>(var i = iE - 1; i &gt;= iB; i--){
        <span class="reserved">if</span>(SAXStrings.WHITESPACE.indexOf(strD.charAt(i)) == -1){
            <span class="reserved">return</span> i;
        }
    }
    <span class="reserved">return</span> -1;
}  <span class="comment">// end function lastIndexOfNonWhitespace</span>


SAXStrings.replace = <span class="reserved">function</span>(strD, iB, iE, strF, strR) {
    <span class="comment">/*******************************************************************************************************************
    function:   replace

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>
    <span class="reserved">if</span>(SAXStrings.isEmpty(strD)) {
        <span class="reserved">return</span> <span class="literal">""</span>;
    }
    iB = iB || 0;
    iE = iE || strD.length;

    <span class="reserved">return</span> strD.substring(iB, iE).split(strF).join(strR);

}  <span class="comment">// end function replace</span>



<span class="comment">/***************************************************************************************************************
Stack: A simple stack class, used for verifying document structure.
*****************************************************************************************************************/</span>

Stack = <span class="reserved">function</span>() {
    <span class="comment">/*******************************************************************************************************************
    function:   Stack

    Author:   Scott Severtson

    Description:
        Constructor of the Stack Object
    *********************************************************************************************************************/</span>
    <span class="reserved">this</span>.m_arr = [];

}  <span class="comment">// end function Stack</span>


Stack.<span class="reserved">prototype</span>.clear = <span class="reserved">function</span>() {
    <span class="comment">/*******************************************************************************************************************
    function:   clear

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>

    <span class="reserved">this</span>.m_arr = [];

}  <span class="comment">// end function clear</span>


Stack.<span class="reserved">prototype</span>.count = <span class="reserved">function</span>() {
    <span class="comment">/*******************************************************************************************************************
    function:   count

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>

    <span class="reserved">return</span> <span class="reserved">this</span>.m_arr.length;

}  <span class="comment">// end function count</span>


Stack.<span class="reserved">prototype</span>.destroy = <span class="reserved">function</span>() {
    <span class="comment">/*******************************************************************************************************************
    function:   destroy

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>

    <span class="reserved">this</span>.m_arr = null;

}   <span class="comment">// end function destroy</span>


Stack.<span class="reserved">prototype</span>.peek = <span class="reserved">function</span>() {
    <span class="comment">/*******************************************************************************************************************
    function:   peek

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>
    <span class="reserved">if</span>(<span class="reserved">this</span>.m_arr.length === 0) {
        <span class="reserved">return</span> null;
    }

    <span class="reserved">return</span> <span class="reserved">this</span>.m_arr[<span class="reserved">this</span>.m_arr.length - 1];

}  <span class="comment">// end function peek</span>


Stack.<span class="reserved">prototype</span>.pop = <span class="reserved">function</span>() {
    <span class="comment">/*******************************************************************************************************************
    function:   pop

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>
    <span class="reserved">if</span>(<span class="reserved">this</span>.m_arr.length === 0) {
        <span class="reserved">return</span> null;
    }

    var o = <span class="reserved">this</span>.m_arr[<span class="reserved">this</span>.m_arr.length - 1];
    <span class="reserved">this</span>.m_arr.length--;
    <span class="reserved">return</span> o;

}  <span class="comment">// end function pop</span>


Stack.<span class="reserved">prototype</span>.push = <span class="reserved">function</span>(o) {
    <span class="comment">/*******************************************************************************************************************
    function:   push

    Author:   Scott Severtson
    *********************************************************************************************************************/</span>

    <span class="reserved">this</span>.m_arr[<span class="reserved">this</span>.m_arr.length] = o;

}  <span class="comment">// end function push</span>



<span class="comment">// =========================================================================</span>
<span class="comment">// =========================================================================</span>
<span class="comment">// =========================================================================</span>

<span class="comment">// CONVENIENCE FUNCTIONS</span>

<span class="comment">// =========================================================================</span>
<span class="comment">// =========================================================================</span>
<span class="comment">// =========================================================================</span>

<span class="reserved">function</span> isEmpty(str) {
    <span class="comment">/*******************************************************************************************************************
    function: isEmpty

    Author: mike<span class="attrib">@idle</span>.org

    Description:
        convenience function to identify an empty string

    *********************************************************************************************************************/</span>
    <span class="reserved">return</span> (str===null) || (str.length==0);

} <span class="comment">// end function isEmpty</span>



<span class="reserved">function</span> trim(trimString, leftTrim, rightTrim) {
    <span class="comment">/*******************************************************************************************************************
    function: trim

    Author: may106<span class="attrib">@psu</span>.edu

    Description:
        helper function to trip a string (trimString) of leading (leftTrim)
        and trailing (rightTrim) whitespace

    *********************************************************************************************************************/</span>
    <span class="reserved">if</span> (isEmpty(trimString)) {
        <span class="reserved">return</span> <span class="literal">""</span>;
    }

    <span class="comment">// the general focus here is on minimal method calls - hence only one</span>
    <span class="comment">// substring is done to complete the trim.</span>

    <span class="reserved">if</span> (leftTrim===null) {
        leftTrim = true;
    }

    <span class="reserved">if</span> (rightTrim===null) {
        rightTrim = true;
    }

    var left=0;
    var right=0;
    var i=0;
    var k=0;


    <span class="comment">// modified to properly handle strings that are all whitespace</span>
    <span class="reserved">if</span> (leftTrim == true) {
        <span class="reserved">while</span> ((i&lt;trimString.length) &amp;&amp; (whitespace.indexOf(trimString.charAt(i++))!=-1)) {
            left++;
        }
    }
    <span class="reserved">if</span> (rightTrim == true) {
        k=trimString.length-1;
        <span class="reserved">while</span>((k&gt;=left) &amp;&amp; (whitespace.indexOf(trimString.charAt(k--))!=-1)) {
            right++;
        }
    }
    <span class="reserved">return</span> trimString.substring(left, trimString.length - right);
} <span class="comment">// end function trim</span>

<span class="comment">/**
 * function __escapeString
 *
 * author: David Joham djoham<span class="attrib">@yahoo</span>.com
 *
 * <span class="attrib">@param</span>  str : string - The string to be escaped
 *
 * <span class="attrib">@return</span> : string - The escaped string
 */</span>
<span class="reserved">function</span> __escapeString(str) {

    var escAmpRegEx = /&amp;/g;
    var escLtRegEx = /&lt;/g;
    var escGtRegEx = /&gt;/g;
    var quotRegEx = /<span class="literal">"/g;
    var aposRegEx = /'/g;

    str = str.replace(escAmpRegEx, "</span>&amp;amp;<span class="literal">");
    str = str.replace(escLtRegEx, "</span>&amp;lt;<span class="literal">");
    str = str.replace(escGtRegEx, "</span>&amp;gt;<span class="literal">");
    str = str.replace(quotRegEx, "</span>&amp;quot;<span class="literal">");
    str = str.replace(aposRegEx, "</span>&amp;apos;<span class="literal">");

  return str;
};

/**
 * function __unescapeString 
 *
 * author: David Joham djoham@yahoo.com
 *
 * @param  str : string - The string to be unescaped
 *
 * @return : string - The unescaped string
 */
function __unescapeString(str) {

    var escAmpRegEx = /&amp;amp;/g;
    var escLtRegEx = /&amp;lt;/g;
    var escGtRegEx = /&amp;gt;/g;
    var quotRegEx = /&amp;quot;/g;
    var aposRegEx = /&amp;apos;/g;

    str = str.replace(escAmpRegEx, "</span>&amp;<span class="literal">");
    str = str.replace(escLtRegEx, "</span>&lt;<span class="literal">");
    str = str.replace(escGtRegEx, "</span>&gt;<span class="literal">");
    str = str.replace(quotRegEx, "</span>\<span class="literal">""</span>);
    str = str.replace(aposRegEx, <span class="literal">"'"</span>);

  <span class="reserved">return</span> str;
};

</pre>
	<hr>



<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top"><em>
<b></b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<font size="-1">

</font>
<div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Mon Nov 14 13:45:39 2011</div>
</body>
</html>
